package com.xscha.tableforge.jooq.tables;

import org.jooq.*;
import org.jooq.Record;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import java.time.LocalDateTime;

/**
 * 视图元数据表
 * 用于存储数据视图的基本信息，包括视图名称、类型、配置等
 */
public class ViewMetaTable extends TableImpl<Record> {

    private static final long serialVersionUID = -1L;

    public static final ViewMetaTable VIEW_META = new ViewMetaTable();

    /** 视图ID */
    public final TableField<Record, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 视图名称 */
    public final TableField<Record, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR.nullable(false), this);
    /** 视图描述 */
    public final TableField<Record, String> DESCRIPTION = createField(DSL.name("description"), SQLDataType.VARCHAR, this);
    /** 所属表ID */
    public final TableField<Record, String> TABLE_ID = createField(DSL.name("table_id"), SQLDataType.VARCHAR.nullable(false), this);
    /** 视图类型 */
    public final TableField<Record, String> TYPE = createField(DSL.name("type"), SQLDataType.VARCHAR.nullable(false), this);
    /** 排序配置 */
    public final TableField<Record, String> SORT = createField(DSL.name("sort"), SQLDataType.VARCHAR, this);
    /** 过滤配置 */
    public final TableField<Record, String> FILTER = createField(DSL.name("filter"), SQLDataType.VARCHAR, this);
    /** 分组配置 */
    public final TableField<Record, String> GROUP = createField(DSL.name("group"), SQLDataType.VARCHAR, this);
    /** 视图选项 */
    public final TableField<Record, String> OPTIONS = createField(DSL.name("options"), SQLDataType.VARCHAR, this);
    /** 显示顺序 */
    public final TableField<Record, Double> DISPLAY_ORDER = createField(DSL.name("display_order"), SQLDataType.DOUBLE.nullable(false), this);
    /** 版本 */
    public final TableField<Record, Integer> VERSION = createField(DSL.name("version"), SQLDataType.INTEGER.nullable(false), this);
    /** 列元数据 */
    public final TableField<Record, String> COLUMN_META = createField(DSL.name("column_meta"), SQLDataType.VARCHAR, this);
    /** 是否启用分享 */
    public final TableField<Record, Boolean> ENABLE_SHARE = createField(DSL.name("enable_share"), SQLDataType.BOOLEAN, this);
    /** 分享ID */
    public final TableField<Record, String> SHARE_ID = createField(DSL.name("share_id"), SQLDataType.VARCHAR, this);
    /** 分享元数据 */
    public final TableField<Record, String> SHARE_META = createField(DSL.name("share_meta"), SQLDataType.VARCHAR, this);
    /** 创建时间 */
    public final TableField<Record, LocalDateTime> CREATED_TIME = createField(DSL.name("created_time"), SQLDataType.LOCALDATETIME(3).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this);
    /** 最后修改时间 */
    public final TableField<Record, LocalDateTime> LAST_MODIFIED_TIME = createField(DSL.name("last_modified_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 删除时间 */
    public final TableField<Record, LocalDateTime> DELETED_TIME = createField(DSL.name("deleted_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 创建人 */
    public final TableField<Record, String> CREATED_BY = createField(DSL.name("created_by"), SQLDataType.VARCHAR.nullable(false), this);
    /** 最后修改人 */
    public final TableField<Record, String> LAST_MODIFIED_BY = createField(DSL.name("last_modified_by"), SQLDataType.VARCHAR, this);
    /** 是否默认视图 */
    public final TableField<Record, Boolean> IS_DEFAULT = createField(DSL.name("is_default"), SQLDataType.BOOLEAN, this);

    private ViewMetaTable() {
        super(DSL.name("view_meta"));
    }

    @Override
    public Schema getSchema() {
        return DSL.schema(DSL.name("public"));
    }

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.VIEW_META_PKEY;
    }

    @Override
    public ViewMetaTable as(String alias) {
        return new ViewMetaTable().as(alias);
    }

    @Override
    public ViewMetaTable as(Name alias) {
        return new ViewMetaTable().as(alias);
    }
} 